package io.shallwe._admin.line;

import com.jfinal.aop.Inject;
import com.jfinal.kit.Ret;

import com.jfinal.plugin.activerecord.Record;
import io.shallwe._admin.permission.Remark;
import io.shallwe.common.controller.BaseController;
import io.shallwe.common.model.TurnoverVehicle;
import io.shallwe.history.ParameterCurveService;

/**
   * 周转车信息
 * @author 王小伟
 * @date   2019-06-10 21:17:33 
 */
public class TurnoverVehicleController extends BaseController{

	@Inject
	TurnoverVehicleService service;
	@Inject
	ParameterCurveService parameterCurveService;
	
	@Remark("周转车信息")
	public void index() {
		checkUrlPara(0);
		render("index.html");
	}
	
	@Remark("周转车信息数据列表")
	public void list() {
		Integer offset = getParaToInt("offset", 1);
		Integer pageSize = getParaToInt("pageSize", 100);
		String traceCode=get("traceCode");
		String rackNo=get("rackNo");
		String vehicleNo=get("vehicleNo");
		
		renderJson(service.paginate(offset, pageSize, traceCode, rackNo, vehicleNo));
	}
	
	@Remark("添加周转车页面")
	public void add() {
		render("add_edit.html");
	}
	
	@Remark("保存添加的周转车信息")
	public void save() {
		TurnoverVehicle vehicle = getBean(TurnoverVehicle.class,"vehicle",true);
		Ret ret = service.save(vehicle);
		renderJson(ret);
	}
	
	@Remark("修改周转车页面")
	public void edit() {
		String id=get("id");
		TurnoverVehicle vehicle = service.findById(id);
		set("vehicle",vehicle);
		render("add_edit.html");
	}
	
	@Remark("保存修改的周转车信息")
	public void update() {
		TurnoverVehicle vehicle = getBean(TurnoverVehicle.class,"vehicle");
		Ret ret = service.update(vehicle);
		renderJson(ret);
	}
	
	
	@Remark("删除周转车信息")
	public void delete() {
		String id = get("id");
		Ret ret =service.delete(id);
		renderJson(ret);
	}
	
	@Remark("追溯完工单打印页面")
	public void print() {
		String id = get("id");
//		TurnoverVehicle vehicle = service.findById(id);
		Record vehicle=service.findPrintPageInfo(id);
		set("vehicle", vehicle);
		render("print.html");
	}

	@Remark("执行追溯完工单打印操作")
	public void doPrint() {
		String id = get("id");
		renderJson(service.doPrint(id));
	}

	@Remark("物件产线详细信息页")
	public void locationDetailPage(){
		String barcode = get("barcode");
		set("barcode",barcode);
		render("location_detail.html");
	}

	@Remark("物件产线详细列表")
	public void locationDetailList(){
		String barcode = get("barcode");
		renderJson(parameterCurveService.findLocationDetailByBarcode(barcode));
	}
}
